<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./css/zTreeStyle/zTreeStyle.css" />
    <script src="./js/jquery-3.6.0.js"></script>
    <script src="./js/jquery.ztree.all.min.js"></script>
  </head>
  <body>
    <div id="nav">
      <ul id="tree" class="ztree"></ul>
    </div>
  </body>
</html>
<script>
  $(function () {
    //对象配置信息
    var settings = {
      data: {
        simpleData: {
          enable: true,
          idKey: 'id',
          pIdKey: 'pid',
          rootPId: '',
        },
      },
    }
    //数据
    var data = [
      { id: 100001, name: '基础信息管理', pid: 0 },
      { id: 100101, name: '人员管理', pid: 100001 },
      { id: 110101, name: '人员列表', pid: 100101 },
      { id: 120101, name: '新增管理', pid: 100101 },

      { id: 200001, name: '基础信息管理2', pid: 0 },
      { id: 200101, name: '人员管理2', pid: 200001 },
      { id: 210101, name: '人员列表2', pid: 200101 },
      { id: 220101, name: '新增管理2', pid: 200101 },
    ]
    //核心方法
    // param1 数据显示  param2 配置信息  param3显示数据
    $.fn.zTree.init($('#tree'), settings, data)
  })
</script>
